import { createStore } from 'redux'

// state
function counter (state = 0, action) {
    switch (action.type) {
        case 'ADD':
            return state + 1
        case 'DEL':
            return state - 1
        default:
            return 10;
    }
}

const store = createStore(counter)

store.subscribe(() => {
    const current = store.getState()
    console.log(`现在个数为${current}个`)
})


store.dispatch({type: 'ADD'})
store.dispatch({type: 'ADD'})